package com.googlecode.bipol.war.session;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;

/**
 * Fake/limited implement of HttpServletRequest
 *
 * @author Claude CHOISNET
 */
public abstract class MockHttpServletRequest
    extends HttpServletRequestDelegator
{
    private final static Logger logger = Logger.getLogger( MockHttpServletRequest.class );
    private String remoteUser;

    public MockHttpServletRequest(
            final HttpServletRequest    httpServletRequest,
            final String                remoteUser
            )
    {
        super( httpServletRequest );

        setRemoteUser( remoteUser );
    }

    //---------------------------------------------------------------

    @Override
    public String getRemoteUser()
    {
        return remoteUser;
    }

    public void setRemoteUser( final String remoteUser )
    {
        this.remoteUser = remoteUser;
    }

    //---------------------------------------------------------------

    @Override
    public boolean isUserInRole( String rolename )
    {
        return mock_isUserInRole( rolename );
    }

    public abstract boolean mock_isUserInRole( String rolename );

    @Override
    public void login( String name, String pass ) throws ServletException
    {
        logger.info( "login( " + name + "," + pass + " )" );

        super.login( name, pass );
    }
}
